{
Function:           _OptimizationPassNr

Description:        Returns optimization pass (iteration) number.

                    EL Collections must be installed for this function to work.

                    Change the TempFile location to your location of choice.

Author:             MarkSanDiego

Updated:            03/30/10    original version
                    04/01/10    replace ListN.PushFront with ListN.Put for increased speed.
                                TempFile now contains only a single row with the iteration number stored in it.
                                Previously, there was a new row created for each iteration.

Usage:              Place the following code in your strategy:
___________________________________________________________________________________________

vars: OptPassNr(0);

once begin
    OptPassNr = _OptimizationPassNr;
end;

___________________________________________________________________________________________
} 


vars:
    Optimizing(GetAppInfo(aiOptimizing) = 1),
    PassList(ListN.New),
    Pass(0),
    TempFile("E:/temp/temp.txt");

    
    once ( Optimizing = false ) begin
        FileDelete(TempFile); 
        FileAppend(TempFile, "0");
        _OptimizationPassNr = 0;
    end;
    
    once (Optimizing = true) begin
        value1 = ListN.ReadFile(PassList, TempFile);
        Pass = ListN.Front(PassList);
        Pass = Pass + 1;
       	value1 = ListN.Put(PassList, 1, Pass);
        value1 = ListN.WriteFile(PassList, TempFile);
        _OptimizationPassNr = Pass;
    end;